<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>作业02_2024-01-25</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=0">
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }
    </style>
    <script>
        let add = (a, b) => a + b;
        let sub = (a, b) => a - b;
        let multi = (a, b) => a * b;
        let div = (a, b) => a / b;

        let showMenu = () => {
            while (true) {
                let c = prompt("欢迎使用简易计算器:\n1. 加法运算;\n2. 减法运算;\n3. 乘法运算;\n4. 除法运算;\n5. 退出:\n请输入您的选项");
                if (c === "5") {
                    return
                } else {
                    let num1 = parseInt(prompt("请输入第一个数"))
                    let num2 = parseInt(prompt("请输入第二个数"))
                    if (c === "1") {
                        alert(add(num1, num2))
                    } else if (c === "2") {
                        alert(sub(num1, num2))
                    } else if (c === "3") {
                        alert(multi(num1, num2))
                    } else if (c === "4") {
                        alert(div(num1, num2))
                    }
                }
            }
        }


        showMenu();

    </script>
</head>
<body>

</body>
</html>